package com.ruyuan.eshop.buyer.controller.trade;

import com.ruyuan.eshop.common.service.trade.order.CheckoutParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * 结算参数控制器
 *
 * @author pwd
 * @version 1.0
 */
@Api(description = "结算参数接口模块")
@RestController
@RequestMapping("/trade/checkout-params")
@Validated
public class CheckoutParamBuyerController {

    @Autowired
    private CheckoutParamService checkoutParamService;


    @ApiOperation(value = "设置收货地址id")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "address_id", value = "收货地址id", required = true, dataType = "int", paramType = "path"),
    })
    @PostMapping(value = "/address-id/{address_id}")
    public boolean setAddressId(@NotNull(message = "必须指定收货地址id") @PathVariable(value = "address_id") Long addressId) {

        //设置收货地址
        return this.checkoutParamService.setAddressId(addressId);

    }

}
